package com.zhhs.project.act.activity.controller;



import com.zhhs.common.utils.poi.ExcelUtil;
import com.zhhs.framework.aspectj.lang.annotation.Log;
import com.zhhs.framework.aspectj.lang.enums.BusinessType;
import com.zhhs.framework.web.controller.BaseController;
import com.zhhs.framework.web.domain.AjaxResult;
import com.zhhs.framework.web.page.TableDataInfo;
import com.zhhs.project.act.activity.domian.ActActivityAdvanced;
import com.zhhs.project.act.activity.service.IActActivityAdvancedService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 高级设置Controller
 *
 * @author zhhs
 * @date 2022-11-09
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/wecom/activity/advanced")
@Slf4j
public class ActActivityAdvancedController extends BaseController
{

    @Autowired
    private IActActivityAdvancedService actActivityAdvancedService;


    /**
     * 查询高级设置列表
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityadvanced:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActActivityAdvanced actActivityAdvanced)
    {
        startPage();
        List<ActActivityAdvanced> list = actActivityAdvancedService.selectActActivityAdvancedList(actActivityAdvanced);
        return getDataTable(list);
    }

    /**
     * 导出高级设置列表
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityadvanced:export')" )
    @Log(title = "高级设置" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(ActActivityAdvanced actActivityAdvanced)
    {
        List<ActActivityAdvanced> list = actActivityAdvancedService.selectActActivityAdvancedList(actActivityAdvanced);
        ExcelUtil<ActActivityAdvanced> util = new ExcelUtil<ActActivityAdvanced>(ActActivityAdvanced.class);
        return util.exportExcel(list, "高级设置数据");
    }

    /**
     * 获取高级设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityadvanced:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(actActivityAdvancedService.selectActActivityAdvancedById(id));
    }

    /**
     * 新增高级设置
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityadvanced:add')" )
    @Log(title = "高级设置" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult addSave(ActActivityAdvanced actActivityAdvanced)
    {
        return toAjax(actActivityAdvancedService.insertActActivityAdvanced(actActivityAdvanced));
    }

//    /**
//     * 修改高级设置
//     */
//    @GetMapping("/edit/{activityId}")
//    public String edit(@PathVariable("activityId") Long activityId, ModelMap mmap)
//    {
//        ActActivityAdvanced actActivityAdvanced = new ActActivityAdvanced();
//        actActivityAdvanced.setActivityId(activityId);
//        List<ActActivityAdvanced> activityAdvancedList = actActivityAdvancedService.selectActActivityAdvancedList(actActivityAdvanced);
//        if (CollectionUtils.isNotEmpty(activityAdvancedList)){
//            mmap.put("actActivityAdvanced", activityAdvancedList.get(0));
//        }
//        return prefix + "/edit";
//    }

    /**
     * 修改高级设置
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityadvanced:edit')" )
    @Log(title = "高级设置" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult editSave(ActActivityAdvanced actActivityAdvanced)
    {
        return toAjax(actActivityAdvancedService.updateActActivityAdvanced(actActivityAdvanced));
    }

    /**
     * 删除高级设置
     */
    @PreAuthorize("@ss.hasPermi('zhhs:activityadvanced:remove')" )
    @Log(title = "高级设置" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable String ids)
    {
        return toAjax(actActivityAdvancedService.deleteActActivityAdvancedByIds(ids));
    }
}
